package com.wuzheng.wisgo.sanitation.cloud.service.person.impl;

import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;
import com.wuzheng.wisgo.sanitation.cloud.repository.entity.person.User;
import com.wuzheng.wisgo.sanitation.cloud.service.person.TokenService;
import com.wuzheng.wisgo.sanitation.framework.core.constant.SysConst;
import org.springframework.stereotype.Service;

/**
 * @author：hibon
 * @date：Created in 2019/10/11
 * @description：token 服务实现类
 * @modified By：
 * @version: 1.0
 */
@Service
public class TokenServiceImpl implements TokenService {

    @Override
    public String getToken(User user) {
        String token = "";
        token = JWT.create()
                .withAudience(user.getId())
                .sign(Algorithm.HMAC256(SysConst.TOKEN_SECRET));
        return token;
    }
}
